import 'package:dio/dio.dart' as dio;

import '../http_init.dart';

class ApiRepository with DioClientInitMixin {
  ApiRepository._();

  static ApiRepository instance = ApiRepository._();

  //==================================================
  Future<String?> getHtmlString(String url,
      {Map<String, dynamic>? queryParameters,
      dio.Options? options,
      dio.CancelToken? cancelToken,
      dio.ProgressCallback? onReceiveProgress}) {
    return httpClient.getString(url,
        queryParameters: queryParameters,
        options: options,
        cancelToken: cancelToken,
        onReceiveProgress: onReceiveProgress);
  }

  Future<dio.Response?> downLoad(
    String urlPath,
    savePath, {
    dio.Dio? d,
    dio.ProgressCallback? onReceiveProgress,
    Map<String, dynamic>? queryParameters,
    dio.CancelToken? cancelToken,
    bool deleteOnError = true,
    String lengthHeader = dio.Headers.contentLengthHeader,
    dio.Options? options,
  }) {
    return (d?.download ?? httpClient.downLoad)(urlPath, savePath,
        onReceiveProgress: onReceiveProgress,
        queryParameters: queryParameters,
        cancelToken: cancelToken,
        deleteOnError: deleteOnError,
        lengthHeader: lengthHeader,
        options: options);
  }
//==================================================
}
